from utils import readeConfig
from appium import webdriver
from src.page import basePage
class loginPage(basePage.BasePage()):

    readeConfigObj = readeConfig.ReadConfig("\\data\\base_xpath.ini")
    loginCenterBtn = readeConfigObj.getConfig('login','loginCenter_btn')
    usernameText = readeConfigObj.getConfig('login', 'username_text')
    passwordText = readeConfigObj.getConfig('login', 'password_text')
    loginBtn = readeConfigObj.getConfig('login', 'login_btn')
    loginSuccess = readeConfigObj.getConfig('login','main_assets')
    dr = basePage.BasePage.getDriver()

    def click_logincenter(self):
        self.dr.find_element_by_id(self.loginCenterBtn).click()

    def input_username(self,username):
        self.dr.find_element_by_id(self.usernameText).send_keys(username)

    def input_password(self,password):
        self.dr.find_element_by_id(self.passwordText).send_keys(password)

    def click_loginbtn(self):
        self.dr.find_element_by_id(self.loginBtn).click()

    #验证是否登录成功
    def login_success(self):
        self.dr.find_element_by_name(self.loginSuccess).text